import 'package:clean_app/interface/mid_interface.dart';
import 'package:flutter/material.dart';

class TabItem {
  final int level;
  final String inputValue;
  final List<TabItem>? options;

  TabItem({
    required this.level,
    required this.inputValue,
    this.options,
  });
}

class TabsProvider extends ChangeNotifier {
  List<TabItem> tabs = [];
  var data = [];

  pullTabs() async {
    var res = await TaskApi().getAllScenes();
    data = res["data"];

    tabs = parseTabItems(data);
    notifyListeners(); // 如果需要通知监听器更新状态
  }

  List<TabItem> parseTabItems(List<dynamic> data) {
    return data.map((item) {
      return TabItem(
        level: item['level'],
        inputValue: item['inputValue'],
        options:
            item['options'] != null ? parseTabItems(item['options']) : null,
      );
    }).toList();
  }
}
